<?php 
namespace app\api\controller\v1;

use think\Controller;

class Menu extends Controller
{
	public function menu (){
		$requests  = input('post.');
		$id  = input('get.id');
		$model = model('menu');
		$data = $model->menu($id);// 查询数据
		if ($data) {
		    $code = 200;
		} else {
		    $code = 404;
		}
		$data = [
		    'code' => $code,
		    'data' => $data
		];
		return json($data);
	}
	public function Mdel()
	{   
	    $id = input('get.id');
	    $model = model('Menu');
	    $data = $model->Mdel($id);//删除数据
	    if ($data) {
	        $code = 200;
	    } else {
	        $code = 404;
	    }
	    $data = [
	        'code' => $code,
	        'data' => $data,
	    ];
	    return json($data);
	}
	public function madd (){
		$requests  = input('post.');
		$id  = input('get.id');
		$model = model('menu');
		$data = $model->madd($id);// 查询数据
		if ($data) {
		    $code = 200;
		} else {
		    $code = 404;
		}
		$data = [
		    'code' => $code,
		    'data' => $data
		];
		return json($data);
	}
	public function mtree(){
		$requests  = input('post.');
		$id  = input('get.id');
		$model = model('menu');
		$data = $model->mtree($id);// 查询数据
		if ($data) {
		    $code = 200;
		} else {
		    $code = 404;
		}
		$data = [
		    'code' => $code,
		    'data' => $data
		];
		return json($data);
	}
	public function add()
	{
	    header('Access-Control-Allow-Origin: *');
	    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
	    header('Access-Control-Allow-Methods: GET, POST, PUT');
	    $shuju = input('post.');
	    $model = model('Menu');
	    $data = $model->add($shuju);// 添加数据
	    if ($data) {
	        $code = 200;
	    } else {
	        $code = 404;
	    }
	    $data = [
	        'code' => $code,
	        'data' => $data
	    ];
	    return json($data);
	}
	
}